﻿using System.Collections.Generic;
using PureMVC.Interfaces;
using PureMVC.Patterns;

public class MyMediator : Mediator {
    public new const string NAME = "MyMediator";

    private MyUI myUI
    {
        get
        {
            return base.ViewComponent as MyUI;
        }
    }

	public override IList<string> ListNotificationInterests()
	{
	    IList<string> listResult=new List<string>();

        listResult.Add("Msg_InitMyUI");
        listResult.Add("Msg_AddCount");
	    return listResult;
	}

	public override void HandleNotification(INotification notification)
	{
        switch (notification.Name)
        {
            case "Msg_InitMyUI":
                MyUI myUI = notification.Body as MyUI;
                this.InitMyUIMediator(myUI);
                break;
            case "Msg_AddCount":
                MyData myData = notification.Body as MyData;
                this.AddCount(myData);
                break;
            default:
                break;
        }
	}

    private void InitMyUIMediator(MyUI myUI)
    {
        if (myUI != null)
        {
            base.m_mediatorName = NAME;
            base.m_viewComponent = myUI;
            myUI.actionBtnCount = this.OnClickAddCount;
        }
    }
    private void OnClickAddCount()
    {
        SendNotification("Cmd_AddCount");
    }
    private void AddCount(MyData myData)
    {
        this.myUI.SetTxtCount(myData);
    }
}